<template>
	<view>
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="item-l">
					<view><text>来访人姓名</text>：{{item.userName}}</view>
					<view><text>来访人电话</text>：{{item.userPhone}}</view>
					<view><text>接待部门</text>：{{item.departName}}</view>
					<view><text>审核人员</text>：{{item.checkUserName}}</view>
					<view><text>校内联系人</text>：{{item.concatName}}</view>
					<view><text>校内联系人电话</text>：{{item.concatPhone}}</view>
					<view><text>校区</text>：{{item.campus}}</view>
					<view><text>入校开始时间</text>：{{item.enrolledTime}}</view>
					<view><text>入校原因</text>：{{item.enrolledReason}}</view>
					<view class="flex-center"><text>邀请码</text>：{{item.inviteCode}}<button class="copy_btn" @click="copy(item.inviteCode)">复制</button></view>
				</view>
				<view class="item-r">
					<text v-if="item.inviteStatus===1">邀请中</text>
					<text v-else class="succ">邀请成功</text>
					
				</view>
			</view>
		</view>
		<view v-if="!list.length" class="no-data">暂无数据！</view>
	</view>
</template>

<script>
	import baseUrl from '../../api/api.js'
	export default {
		data() {
			return {
				params: {
					current: 1,
					size: 10
				},
				list: []
			}
		},
		onLoad() {
			this.getRecord()
		},
		onReachBottom() {
			this.params.current++
			this.getRecord()
		},
		methods: {
			copy(text) {
				uni.setClipboardData({
					data: text
				})
			},
			getRecord() {
				uni.showLoading({
					title: ''
				})
				uni.request({
					url: baseUrl.baseUrl + "zkd/teacher/invite/record/page",
					method: 'GET',
					header: {
						'content-type': 'application/x-www-form-urlencoded' //自定义请求头信息
					},
					data: {
						...this.params,
						concatGid: this.getParam(location.href, "concatGid")
					},
					success:(res) => {
						this.list = [...this.list, ...res.data.data.records]
						uni.hideLoading()
					},
					fail(err) {
						console.log(err)
						uni.hideLoading()
					}
				})
			},
			getParam(path, name) {
				var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
				if (reg.test(path))
					return decodeURIComponent(RegExp.$2.replace(/\+/g, " "));
				return "";
			},
		}
	}
</script>

<style lang="scss">
.flex-center {
	display: flex;
	align-items: center;
}
.copy_btn {
	background: #004D95;
	color: #fff;
	min-width: 100rpx;
	height: 60rpx;
	font-size: 24rpx;
	display: inline-block;
	margin-left: 20rpx;
}
.item {
	background: #fff;
	margin: 30rpx;
	border-radius: 16rpx;
	padding: 20rpx;
	display: flex;
	justify-content: space-between;
	
	>.item-l view{
		margin-bottom: 20rpx;
		font-size: 30rpx;
	}
	
	.item-r {
		position: absolute;
		right: 60rpx;
		width: 100px;
		padding-bottom: 20rpx;
		text-align: right;
		color: #666;
		.succ {
			color: #81B80B;
		}
	}
}
.no-data {
	text-align: center;
	margin: 100rpx;
	color: #999;
}
</style>
